package com.bite.book.Enum;

import lombok.Data;
import lombok.Getter;


public enum BookStatus {
    DELETED(0,"无效"),
    NORMAL(1,"可借阅"),
    FORBIDDEN(2,"不可借阅");

    @Getter
    private Integer code;
    @Getter
    private String name;

    BookStatus(int code, String name){
        this.code = code;
        this.name = name;
    }

    public static String getNameByCode(Integer code){
        for(BookStatus bookStatus: BookStatus.values()){
            if(bookStatus.getCode() == code){
                return bookStatus.getName();
            }
        }
        return null;
    }
}
